package org.example.jnautil.mouse;

import com.sun.glass.events.MouseEvent;
import lombok.Getter;

import java.lang.reflect.Field;

@Getter
public enum MouseCodeName {

    MOUSEMOVE(512, "MOUSE_MOVE"),
    LBUTTONDOWN(513, "LEFT_DOWN"),
    LBUTTONUP(514, "LEFT_UP"),
    RBUTTONDOWN(516, "RIGHT_DOWN"),
    RBUTTONUP(517, "RIGHT_UP"),
    MBUTTONDOMN(519, "MIDDLE_DOMN"),
    MBUTTONUP(520, "MIDDLE_UP"),
    SCROOL(522, "SCROOL");
    final int code;
    final String readableName;

    MouseCodeName(int code, String readableName) {
        this.code = code;
        this.readableName = readableName;
    }

    static MouseCodeName byCode(int code) {
        for (MouseCodeName value : MouseCodeName.values()) {
            if (code == value.code) {
                return value;
            }
        }
        return null;
    }

    public static void main(String[] args) throws Exception {

        for (Field declaredField : MouseEvent.class.getDeclaredFields()) {
            String pattern = "%s(%s,\"%s\"),";
            String name = declaredField.getName();
            Object o = declaredField.get(MouseEvent.class);
            System.out.println(String.format(pattern, name, o, name));
        }
    }
}
